import acm.program.ConsoleProgram;


/**
 * Created by IntelliJ IDEA.
 * User: scotthatcher
 * Date: Mar 24, 2010
 * Time: 12:20:38 PM
 * To change this template use File | Settings | File Templates.
 */
public class ReplaceOccurrence extends ConsoleProgram {

    private int countUpperCase(String str){
        int count = 0;
        for (int i=0; i<str.length(); i++){
            char ch = str.charAt(i);
            if(Character.isUpperCase(ch)){
                count++;

            }
       }
             return (count);
    }

    private String replaceOccurrence(String str,
             String orig, String repl){

        int index = str.indexOf(orig);
        if (index!= -1){
            str = str.substring(0,index) + repl +
                    str.substring(index + orig.length());

        }
        println (str);
        return str;
    }

    public void run(){
        String Sentance = "I Love Cats";
        String orig = "Love";
        String repl = "Hate";
        replaceOccurrence(Sentance,orig,repl);

    }


}
